package com.sdkx.wear_os.ui.activity

import androidx.lifecycle.ViewModelProvider
import com.sdkx.wear_os.base.BaseActivity
import com.sdkx.wear_os.base.BaseViewModel
import com.sdkx.wear_os.R
import com.sdkx.wear_os.databinding.ActivityErrorBinding
import com.sdkx.wear_os.retrofit.Parameter

/**
 * 发生崩溃时跳转
 * 错误页面
 */
class ErrorActivity : BaseActivity<BaseViewModel, ActivityErrorBinding>() {

    override fun initLayout() = R.layout.activity_error
    override fun initView() {
        mDataBinding.toolbarTitle = "发生错误了"
        initToolbar(mDataBinding.layoutToolbar.toolbar)
        mDataBinding.errorContent.text = intent.getStringExtra("error")
        //声明viewModel
        val mViewModel = ViewModelProvider(this)[BaseViewModel::class.java]
        //设置参数
        val parameter = Parameter()
        parameter.errorContent = mDataBinding.errorContent.text.toString()
        //上传错误日志
        mViewModel.uploadError(parameter)
    }

    override fun initData() {
    }

    override fun initListener() {
        //返回
        mDataBinding.layoutToolbar.toolbarBackIv.setOnClickListener { finish() }
    }
}